﻿using System;
using System.Collections.Generic;
using System.Text;
using PacMan3D.Utils;
using Tao.FreeGlut;
using Tao.OpenGl;

namespace PacMan3D.Camera
{
    public class Observer
    {
        private float IncrementStatusX = 0;
        private float IncrementStatusY = 0;
        private float IncrementStatusZ = 0;

        public Point3D Position { get; private set; }
        public Point3D Center { get; set; }

        public Observer()
            : this(new Point3D(), new Point3D()) 
        {
        }

        public Observer(Point3D position)
            :this(position, new Point3D(0.0f, 0.0f, 0.0f))
        {
        }

        public Observer(Point3D position, Point3D center)
        {
            this.Position = position;
            this.Center = center;
        }

        public void Watch()
        {
            Point3D finalPosition = GetFinalPosition();
            Glu.gluLookAt(finalPosition.X, finalPosition.Y, finalPosition.Z, this.Center.X, this.Center.Y, this.Center.Z, 0, 1, 0);
        }

        public void IncreaseX(float amount)
        {
            this.IncrementStatusX += amount;
        }

        public void DecreaseX(float amount)
        {
            this.IncrementStatusX -= amount;
        }

        public void IncreaseY(float amount)
        {
            this.IncrementStatusY += amount;
        }

        public void DecreaseY(float amount)
        {

            this.IncrementStatusY -= amount;
        }

        public Point3D GetFinalPosition()
        {
            return new Point3D(this.Position.X + this.IncrementStatusX, this.Position.Y + this.IncrementStatusY, this.Position.Z + this.IncrementStatusZ);
        }

        public override string ToString()
        {
            return "Observer{PosX:" + this.Position.X + ", PosY:" + this.Position.Y + ", PosZ:" + this.Position.Z + "}";
        }
    }
}
